/*
 * @Author: 万仁杰
 * @Date: 2020-08-10 10:53:10
 * @LastEditTime: 2020-08-13 01:41:08
 * @LastEditors: 万仁杰
 * @Description: 配置类
 * @FilePath: \BackEnd\saleflower\src\main\java\com\wangwang\saleflower\config\WebMvcConfig.java
 */
package com.wangwang.saleflower.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**")
                        .allowedOrigins("http://localhost:8086")
                        .allowCredentials(true)
                        .allowedMethods("GET", "POST", "DELETE", "PUT","PATCH")
                        .allowedHeaders("*")
                        .maxAge(36000);
            }
        };
    }
}